home *** CD-ROM | disk | FTP | other *** search
- function dmCheckForVictory()
- local scenario = GetProperties()
-
- local player = GetPlayerColor()
- local opponent = GetOpponentColor()
- local OurUnits = GetAliveUnitsAmount(player)
- local EnemyUnits = GetAliveUnitsAmount(opponent)
-
- if HasSurrendered(player) then return GAMERESULT_DEFEAT end
- if HasSurrendered(opponent) then return GAMERESULT_VICTORY end
-
- if (OurUnits == 0 and GetTurnNumber(player) > 1) then return GAMERESULT_DEFEAT end
- if (EnemyUnits == 0 and GetTurnNumber(player) > 1) then return GAMERESULT_VICTORY end
-
- local Balance = GetBalance()
- if (Balance <= -100) then return GAMERESULT_DEFEAT end
- if (Balance >= 100 and scenario.iVictoryCondition == 0) then return GAMERESULT_VICTORY end
- return GAMERESULT_NONE
- end
-
- function dmShowObjectives()
- local scenario = GetProperties()
-
- if scenario.iVictoryCondition == 0 then
- AddObjective("dm_objective")
- else
- AddObjective("dm_objective2")
- end
- end
-
- ---------------------------------------------------
-
- function IsPerished(unit)
- return IsDeployed(unit) and IsDead(unit)
- end
-
- function WaitForAnimationEnd()
- while ( IsAnyAnimationActive() and IsVisual() ) do
- pause()
- end
- end
-
- function WaitForCameraMotionEnd()
- while ( IsCameraActive() and IsVisual() ) do
- pause()
- end
- end
-
- function WaitForSoundEnd(sound_type)
- while( IsSoundActive(sound_type) ) do
- pause()
- end
- end
-
- function WaitForTypingEnd()
- while ( IsTypingActive() ) do
- pause()
- end
- end
-
- --------------------------------------------
-
- function FinishMOB()
- WaitForCameraMotionEnd()
- WaitForAnimationEnd()
- _FinishMOB()
- end
-
- function RemoveDead()
- WaitForAnimationEnd()
- _RemoveDead()
- end
-
- function SetHP(nUnitID, nValue)
- WaitForAnimationEnd()
- _SetHP(nUnitID, nValue)
- end
-
- function SafePlaySound( audio_fn )
- if DoesFileExist( audio_fn ) then
- PlaySound(audio_fn)
- WaitForSoundEnd(ENET_EFFECT_SOUND_DIRECTSOUND)
- else
- delay(0)
- local error = string.format("sound '%s' not found", audio_fn)
- LogError(error)
- end
- end
-
- function ShowBallon(nID, nUnitType, nAlignType, hex_x, hex_y, message)
- WaitForCameraMotionEnd()
- ReduceMusicVolume()
- _ShowBallon(nID, nUnitType, nAlignType, hex_x, hex_y, message)
- local audio_fn = string.format("%s.ogg", message)
- SafePlaySound(audio_fn)
- HideBallon(nID)
- RestoreMusicVolume()
- end
-
- function ShowXBallon(nID, nUnitType, nAlignType, x, y, message)
- ReduceMusicVolume()
- WaitForCameraMotionEnd()
- _ShowXBallon(nID, nUnitType, nAlignType, x, y, message)
- local audio_fn = string.format("%s.ogg", message)
- SafePlaySound(audio_fn)
- HideBallon(nID)
- RestoreMusicVolume()
- end
-
- function FlyCamera(_11, _12, _13, _14, _21, _22, _23, _24, _31, _32, _33, _34, _41, _42, _43, _44)
- WaitForCameraMotionEnd()
- _FlyCamera(_11, _12, _13, _14, _21, _22, _23, _24, _31, _32, _33, _34, _41, _42, _43, _44)
- end
-
- function ShowSpeechBallonX(Character, message, audio_fn)
- WaitForCameraMotionEnd()
- ReduceMusicVolume()
- _ShowBallon(-12345, -1, MBS_SPEECH, 1, 1, message)
- AdjustBallon(-12345, 0, 200, 150)
- ShowCharacter(Character.medium, Character.name)
- SafePlaySound(audio_fn)
- HideBallon(-12345)
- HideCharacters()
- RestoreMusicVolume()
- end
-
- function SetUnitNameX(uid, Character)
- SetUnitName(uid, Character.name, Character.medium)
- end
-
- function AddToChatX(nPos, Character, rank)
- AddToChat(nPos, Character.avatar, Character.picture, Character.medium, 7, Character.name)
- end
-
- function AddRemark(nCharacter, key, audio_fn)
- pause()
- WaitForSoundEnd(ENET_EFFECT_SOUND_DIRECTSOUND)
- WaitForTypingEnd()
- pause(0.5)
- FadeOut(nCharacter)
- while ( IsBigFadeGoing() ) do
- pause()
- end
- _AddRemark(nCharacter, key, audio_fn)
- while ( IsBigFadeGoing() ) do
- pause()
- end
- pause()
- WaitForSoundEnd(ENET_EFFECT_SOUND_DIRECTSOUND)
- RemoveSoundIcon()
- WaitForTypingEnd()
- end
-
- function FinishBriefing()
- pause(0.1)
- WaitForSoundEnd(ENET_EFFECT_SOUND_DIRECTSOUND)
- WaitForTypingEnd()
- -- _FinishBriefing()
- end
-
- -- the same as FinishBriefing
- function Intro(text, audio)
- pause(0.1)
- WaitForSoundEnd(ENET_EFFECT_SOUND_DIRECTSOUND)
- WaitForTypingEnd()
- _Intro(text, audio)
- end
-
- function AddToChat(nID, avatar, big_picture, medium_picture, rank, key)
- WaitForTypingEnd()
- _AddToChat(nID, avatar, big_picture, medium_picture, rank, key)
- while (IsFadingActive(nID)) do
- pause()
- end
- end
-
- function StartBriefing()
- pause(0.1)
- WaitForSoundEnd(ENET_EFFECT_SOUND_DIRECTSOUND)
- WaitForTypingEnd()
- _StartBriefing()
- WaitForSoundEnd(ENET_EFFECT_SOUND_DIRECTSOUND)
- WaitForTypingEnd()
- BriefingConnect()
- WaitForTypingEnd()
- BriefingLogin()
- end
-
- function SetCapitalModel(nID, nModel)
- _SetCapitalModel(nID, nModel)
- if ( nModel ~= ENET_UNIT_CAPITAL_LARGE and nModel ~= ENET_UNIT_CAPITAL_MEDIUM and nModel ~= ENET_UNIT_CAPITAL_SMALL ) then
- SetAirport( nID, false )
- end
- end
-
- local old_prompt = ""
-
- function ShowPrompting(prompt)
- _ShowPrompting(prompt)
- if prompt ~= old_prompt then
- local audio_fn = string.format("%s.wav", prompt)
- if DoesFileExist( audio_fn ) then
- PlaySound(audio_fn)
- end
- old_prompt = prompt
- end
- end
-
- function IncorrectAction(message)
- pause()
- stop()
-
- StartMOB(1)
-
- ShowXBallon(51, -1, MBS_CENTER, 300, 300, message)
-
- FinishMOB()
-
- Undo()
-
- old_prompt = ""
- end